package com.vichat.api.entity;



import com.vichat.common.util.DateUtil;

import javax.persistence.*;
import java.util.Date;

/***************
 *author: autogen
 *version: 2017-12-23 15:03:51.035
 */
@Entity
@Table(name = "response_busi_record" )
public class ResponseBusiRecord implements java.io.Serializable{

	private static final long serialVersionUID = 1L;
	


    public static final String TABLE = "response_busi_record";

    /** */
	public static final String ALIAS_RESPONSE_ID = "response_id";
    /** */
	public static final String ALIAS_JSON_ID = "json_id";
    /** */
	public static final String ALIAS_APP_ID = "app_id";
    /** */
	public static final String ALIAS_METHOD = "method";
    /** */
	public static final String ALIAS_SIGN = "sign";
    /** */
	public static final String ALIAS_TRANSACTION_ID = "transaction_id";
    /** */
	public static final String ALIAS_RESPONSE_CODE = "response_code";
    /** */
	public static final String ALIAS_RESPONSE_MSG = "response_msg";
    /** */
	public static final String ALIAS_RESULT_CODE = "result_code";
    /** */
	public static final String ALIAS_RESULT_MSG = "result_msg";
    /** */
	public static final String ALIAS_TIMESTAMP = "timestamp";
    /** */
	public static final String ALIAS_DONE_CODE = "done_code";
    /** */
	public static final String ALIAS_STATE = "state";
    /** */
	public static final String ALIAS_CREATE_TIME = "create_time";
	
	

 	@Id
@   GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "response_id", unique = true, nullable = false)
    public Long responseId;

 	@Column(name = "json_id")
    public Long jsonId;

 	@Column(name = "app_id")
    public String appId;

 	@Column(name = "method")
    public String method;

 	@Column(name = "sign")
    public String sign;

 	@Column(name = "transaction_id")
    public String transactionId;

 	@Column(name = "response_code")
    public String responseCode;

 	@Column(name = "response_msg")
    public String responseMsg;

 	@Column(name = "result_code")
    public String resultCode;

 	@Column(name = "result_msg")
    public String resultMsg;

 	@Column(name = "timestamp")
    public String timestamp;

 	@Column(name = "done_code")
    public Long doneCode;

 	@Column(name = "state")
    public Long state;

 	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
    public Date createTime;






	public Long getResponseId() {
		return this.responseId;
	}

	public void setResponseId(Long value) {
		this.responseId = value;
	}

	public Long getJsonId() {
		return this.jsonId;
	}

	public void setJsonId(Long value) {
		this.jsonId = value;
	}

	public String getAppId() {
		return this.appId;
	}

	public void setAppId(String value) {
		this.appId = value;
	}

	public String getMethod() {
		return this.method;
	}

	public void setMethod(String value) {
		this.method = value;
	}

	public String getSign() {
		return this.sign;
	}

	public void setSign(String value) {
		this.sign = value;
	}

	public String getTransactionId() {
		return this.transactionId;
	}

	public void setTransactionId(String value) {
		this.transactionId = value;
	}

	public String getResponseCode() {
		return this.responseCode;
	}

	public void setResponseCode(String value) {
		this.responseCode = value;
	}

	public String getResponseMsg() {
		return this.responseMsg;
	}

	public void setResponseMsg(String value) {
		this.responseMsg = value;
	}

	public String getResultCode() {
		return this.resultCode;
	}

	public void setResultCode(String value) {
		this.resultCode = value;
	}

	public String getResultMsg() {
		return this.resultMsg;
	}

	public void setResultMsg(String value) {
		this.resultMsg = value;
	}

	public String getTimestamp() {
		return this.timestamp;
	}

	public void setTimestamp(String value) {
		this.timestamp = value;
	}

	public Long getDoneCode() {
		return this.doneCode;
	}

	public void setDoneCode(Long value) {
		this.doneCode = value;
	}

	public Long getState() {
		return this.state;
	}

	public void setState(Long value) {
		this.state = value;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date value) {
		this.createTime = value;
	}



	public ResponseBusiRecord() {
	}

	public ResponseBusiRecord(boolean qryflag) {
	    if(qryflag){
	    		this.responseId = null;
				this.jsonId = null;
				this.appId = null;
				this.method = null;
				this.sign = null;
				this.transactionId = null;
				this.responseCode = null;
				this.responseMsg = null;
				this.resultCode = null;
				this.resultMsg = null;
				this.timestamp = null;
				this.doneCode = null;
				this.state = null;
				this.createTime = null;
			    }
	}


	public ResponseBusiRecord(
	    Long inResponseId,
	    Long inJsonId,
	    String inAppId,
	    String inMethod,
	    String inSign,
	    String inTransactionId,
	    String inResponseCode,
	    String inResponseMsg,
	    String inResultCode,
	    String inResultMsg,
	    String inTimestamp,
	    Long inDoneCode,
	    Long inState,
		Date inCreateTime
	 ) {
		super();
				this.responseId = inResponseId;
				this.jsonId = inJsonId;
				this.appId = inAppId;
				this.method = inMethod;
				this.sign = inSign;
				this.transactionId = inTransactionId;
				this.responseCode = inResponseCode;
				this.responseMsg = inResponseMsg;
				this.resultCode = inResultCode;
				this.resultMsg = inResultMsg;
				this.timestamp = inTimestamp;
				this.doneCode = inDoneCode;
				this.state = inState;
				this.createTime = inCreateTime;
			}




    @Transient
    private String responseContent;

    public String getResponseContent() {
        return responseContent;
    }

    public void setResponseContent(String responseContent) {
        this.responseContent = responseContent;
    }





    @Transient
    private VichatJson edposJson;

    public VichatJson getEdposJson() {
        return edposJson;
    }

    public void setEdposJson(VichatJson edposJson) {
        this.edposJson = edposJson;
    }

    public static ResponseBusiRecord convert(RequestBusiRecord request) {
        ResponseBusiRecord response = new ResponseBusiRecord();
        response.setAppId(request.getAppId());
        response.setMethod(request.getMethod());
        response.setTransactionId(request.getTransactionId());
        response.setTimestamp(DateUtil.getFormattedDate(new Date(),"yyyyMMddHHmmss"));
		response.setAppType(request.getAppType());
        return  response;
    }


	public String getAppType() {
		return appType;
	}

	public void setAppType(String appType) {
		this.appType = appType;
	}

	private String appType = "C";//C: COMPANY  S:SYSTEM

}

